import axios from "axios";
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { ElLoading } from 'element-plus'

let loadingInstance:any 

NProgress.configure({ showSpinner: false });

const request = axios.create({
  timeout:50000,
  baseURL:"/app"
})
request.interceptors.request.use((config)=>{
  NProgress.start()
  loadingInstance =  ElLoading.service({
    text:"加载中"
  })
  return config
})
request.interceptors.response.use((res)=>{
  NProgress.done()
  loadingInstance.close()
  return res.data
})
export default request